package cn.itsource.easyexcel.write;

import cn.itsource.constant.Constant;
import cn.itsource.util.GenerateUserUtil;
import cn.itsource.vo.User;
import com.alibaba.excel.EasyExcel;

import java.util.HashSet;
import java.util.Set;

/**
 * 指定模型中的列写入
 */
public class WriteDemo4 {
    public static void main(String[] args) {
        String filename = Constant.BATH_URL + "user4.xlsx";
        // 设置要导出的字段
        Set<String> includeFields = new HashSet<>();
        includeFields.add("userName");
        includeFields.add("hireDate");
        // 写Excel
        EasyExcel.write(filename, User.class)
                .includeColumnFiledNames(includeFields)
                .sheet("用户信息")
                .doWrite(GenerateUserUtil.getUserData());
    }
}
